/**
 * Created by Administrator on 2019/1/1.
 */
package com.game.fg.service;
class MessageBuild {
    //玩家进入游戏返回数据包
    static byte[] responseEnterGame(Message.EnumErrorCode error, int money, int cfgBuyTNum, int cfgBuyCNum, int cfgSaleTNum, int cfgSaleCNum,
                                    int dBuyTNum, int dBuyCNum, int dSaleTNum, int dSaleCNum) {
        Message.ResponseEnterGame.Builder builder = Message.ResponseEnterGame.newBuilder();
        builder.setError(error);
        //金币
        builder.setMoney(money);
        //房间报名费
        builder.setEntryOfJunior(FGConfig.getInstance().entryFeeOfJunior);
        builder.setEntryOfMiddle(FGConfig.getInstance().entryFeeOfMiddle);
        builder.setEntryOfSunior(FGConfig.getInstance().entryFeeOfSenior);
        //房间最高可获得金币数量
        builder.setMaxMoneyOfJunior(9999);
        builder.setMaxMoneyOfMiddle(9999);
        builder.setMaxMoneyOfSunior(99999);
        //每日兑换次数相关
        builder.setIBuyNum(dBuyTNum);
        builder.setIBuyMaxNum(cfgBuyTNum);

        builder.setIBuyCoin(dBuyCNum);
        builder.setIBuyMaxCoin(cfgBuyCNum);

        builder.setISubNum(dSaleTNum);
        builder.setISubMaxNum(cfgSaleTNum);

        builder.setISubCoin(dSaleCNum);
        builder.setISubMaxCoin(cfgSaleCNum);
        Message.ResponseEnterGame data = builder.build();
        return data.toByteArray();
    }

    //开始游戏返回数据包
    static byte[] responseStartGame(Message.EnumErrorCode error) {
        Message.ResponseStartGame.Builder builder = Message.ResponseStartGame.newBuilder();
        builder.setError(error);
        Message.ResponseStartGame data = builder.build();
        return data.toByteArray();
    }

    //猜拳返回数据包
    static byte[] responsePlayGame(Message.EnumErrorCode error, Message.EnumGameResult res, int changeMoney, int leftMoney) {
        Message.ResponsePlayGame.Builder builder = Message.ResponsePlayGame.newBuilder();
        builder.setError(error);
        builder.setRes(res);
        builder.setChangeMoney(changeMoney);
        builder.setLeftMoney(leftMoney);
        Message.ResponsePlayGame data = builder.build();
        return data.toByteArray();
    }

    //离开游戏返回数据包
    static byte[] responseExitGame(Message.EnumErrorCode error) {
        Message.ResponseExitGame.Builder builder = Message.ResponseExitGame.newBuilder();
        builder.setError(error);
        Message.ResponseExitGame data = builder.build();
        return data.toByteArray();
    }

    //兑换金币数据包
    static byte[] responseExchange(Message.EnumErrorCode error, int type, int value, int money) {
        Message.ResponseExchange.Builder builder = Message.ResponseExchange.newBuilder();
        builder.setError(error);
        builder.setType(type);
        builder.setValue(value);
        builder.setMoney(money);
        Message.ResponseExchange data = builder.build();
        return data.toByteArray();
    }

    //公告数据包
    static byte[] systemNotice(String content) {
        Message.SystemNotice.Builder builder = Message.SystemNotice.newBuilder();
        builder.setContent(content);
        Message.SystemNotice data = builder.build();
        return data.toByteArray();
    }

    //踢除玩家数据包
    static byte[] kickOff() {
        Message.KickOff.Builder builder = Message.KickOff.newBuilder();
        Message.KickOff data = builder.build();
        return data.toByteArray();
    }

}
